//=========================================引脚接线================================================//
//   VCC         接       DC 5V/3.3V      //MPU9250电源正
//   GND         接          GND          //MPU9250电源地
//=======================================液晶屏数据线接线==========================================//
//   SCL         接          PA9         //MPU9250 IIC 时钟信号
//   SDA         接          PA10        //MPU9250 IIC 数据信号
//=================================================================================================//

#include "Task_mpu.h"
QueueHandle_t Usart7_sem;




#define Mpu9250_TASK_PRIO 6
#define Mpu9250_STK_SIZE 512
TaskHandle_t Mpu9250Task_Handler;
void Task_Mpu9250(void *pvParameters);
//IMU_Data_t IMU_Data;
char buff[UART7_BUFLEN] = {0};


unsigned char Cmd_CompassMeasure[] = {0x68,0x04,0x00,0x04,0x08,'\r'};//同时读pich roll head

uint32_t num;
void Task_mpu9250_Create(void)
{
	
	  xTaskCreate((TaskFunction_t )Task_Mpu9250,            //任务函数
                (const char*    )"Task_Mpu9250",          //任务名称
                (uint16_t       )Mpu9250_STK_SIZE,        //任务堆栈大小
                (void*          )NULL,                //传递给任务函数的参数
                (UBaseType_t    )Mpu9250_TASK_PRIO,       //任务优先级
                (TaskHandle_t*  )&Mpu9250Task_Handler);   //任务句柄    
		Usart7_sem = xSemaphoreCreateBinary();
		//Usart7_sem = xSemaphoreCreateCounting(2,1);        /* 计数信号量创建 */								
}

extern void CompassdAnalyse(char *buf);
void Task_Mpu9250(void *pvParameters)
{

	
	
	while(1)
	{
		
		
		if(xSemaphoreTake(Usart7_sem, portMAX_DELAY) == pdTRUE)
		{
				strncpy(buff, (const char *)Usart7_RXBUF,UART7_BUFLEN - 1);
				//SEGGER_RTT_printf(0, "Usart7_RXBUF\n");
				CompassdAnalyse(buff);
			
//				Analyse_JY3100((uint8_t *)buff);
//				memset(buff,0,UART7_BUFLEN);
//				usart_dma_receiver_enable(UART7, TRUE);         //开启USART1 DMA 接收
//				dma_channel_enable(DMA1_CHANNEL3, TRUE);        //开启通道2（开始接收）
		}
	}
}






